//
//  LeftView.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "LeftView.h"

@interface LeftView()

@property (nonatomic ,strong) UILabel *telephoneAdress;
@property (nonatomic ,strong) UILabel *line;

@property (nonatomic ,strong) UIImageView *trigon;


@end

@implementation LeftView


- (UILabel *)telephoneAdress {
    if (!_telephoneAdress) {
        _telephoneAdress = [[UILabel alloc] init];
        _telephoneAdress.textColor = [UIColor lightGrayColor];
        _telephoneAdress.text = @"+86";
        
        [self addSubview:_telephoneAdress];

    }
    
    return _telephoneAdress;
}


- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = [UIColor greenColor];
        [self addSubview:_line];
    }
    return _line;
}

-(UIImageView *)trigon {

    if (!_trigon) {
        _trigon = [[UIImageView alloc] init];
        _trigon.image = [UIImage imageNamed:@"san"];
        [self addSubview:_trigon];
    }
    return _trigon;
}


- (void)drawRect:(CGRect)rect {    
    
    WEAKSELF;
    
   CGFloat width = [self.telephoneAdress.text widthWithFont:[UIFont systemFontOfSize:12.f] constrainedToHeight:45.f];
    [self.telephoneAdress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.mas_left).with.offset(8);
        make.width.mas_equalTo([NSNumber numberWithFloat:width+15]);
        make.top.equalTo(weakSelf.mas_top).offset(0);
    }];
    
    [self.trigon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.telephoneAdress.mas_right).with.offset(-2);
        make.size.mas_equalTo(CGSizeMake(7,7));

    }];

    
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.trigon.mas_right).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(3,20.f));
        
    }];
    


}


@end
